package com.moody.service;

import java.util.List;
import org.springframework.stereotype.Service;

import com.moody.hibernate.domain.AdjValue;
import com.moody.hibernate.domain.LgdH;
import com.moody.hibernate.domain.PdH;
import com.moody.hibernate.domain.QuaValue;
import com.moody.hibernate.domain.QuaValueId;
import com.moody.hibernate.domain.RatioValue;

/*
 * Copyright © Moody analytics
 *
 * @Author: Wang Fuqiang
 * @Time: 2011-11-9 上午10:58:03
 * @Modified by: 
 * @Description: 
 */
@Service
public interface RatingService {

	List<PdH> findHistoryRatingPdH(String custId);

	List<PdH> listCustSortedRating();

	PdH getNewestPDByCustId(String custId);
	
	List<PdH> findReportHistoryRatingPdH(String ratingCustId);

	PdH findPDById(String serialNo);

	void insertLGD(LgdH lgdH);

	void insertPdH(PdH pd);

	QuaValue findQuaValueBySerialNoModelIdAndItemNo(String serialNo, String modelId, String itemNo);

	void insertQuaValueList(List<QuaValue> list);

	QuaValue findQuaValueById(QuaValueId id);

	List<QuaValue> findQuaValueBySerialNoAndModelId(String serialNo,String modelId);

	void deleteQuaValue(QuaValue qv);

	List<AdjValue> findAdjValueBySerialNoAndModelId(String serialNo,String modelId);

	AdjValue findAdjValueBySerialNoModelIdAndItemNo(String serialNo,String modelId, String itemNo);

	void insertAdjValueList(List<AdjValue> list);

	public RatioValue findRatioValueByRatioValueId(com.moody.hibernate.domain.RatioValueId id);
	
	List<RatioValue> findRatioValueBySerialNoAndModelId(String serialNo,String modelId);

	void insertRatioValueList(List<RatioValue> ratioValueList);

	void updatePdH(PdH ratingPD);

	PdH findRecentPDByCustId(String custId);

	List<PdH> listCustSortedRatingByConfirmDate();
	
	/**
	 * 通过用户信息，查询所属客户的评级信息
	 * @param userId
	 * @param orgId
	 * @param isRetail
	 * @return
	 */
	List<PdH> listCustSortedRatingByUser(String userId,String orgId,boolean isRetail);
	
	/**
	 * 将该客户所有评级状态中的pdh数据设置为失效状态。主要用于评级进行中又发起新的评级，原进行中的评级数据失效
	 * @param custId
	 */
	public void invalidatePdH(String custId);
	
	public int getConfirmedOrderByConfirmDate(String serialNo,String confirmDate);
	
	public int getIndConfirmedOrderBySecondDate(String serialNo,String secondDate);
	
	/**
	 * 获得某抵质押在某债项的份额半分比
	 * @param debtNo
	 * @param collateralId
	 * @param exposureValueTemp 用于计算的债项余额，未必等同于真正的债项余额
	 * @return
	 */
	public double getShare(String debtNo, double exposureValueTemp,String collateralId);
	
}
